/**
 * *****************************************************************
 * @file    adt3102_pmu.h
 * @author  WuHao(hwu@andartechs.com.cn)
 * @version 1.0.0
 * @date    2020-11-09
 * @brief   
 *                 Copyright (c) 2020, Andar Technologies Inc.
 *                           www.andartechs.com 
 *
 * *****************************************************************
 */
#ifndef __PMU__H
#define __PMU__H
/*------------------------------ include -------------------------------------*/
#include "adt3102_type_define.h"


/*------------------------------ function ------------------------------------*/
/**
 * @brief   adt3102 power setting.
 * @param   onOroff: power on plli pll, plli vco, plln pll, plln vco, bb1 and bb2, 
 *                  bias1 and so on.
 * @return  None.
 * @note
 */
void adt3102PowerSw(int onOroff);

/**
 * @brief   select high_clk as 50MHz.
 * @param   None.
 * @return  None.
 * @note
 */
void switchTo50m(void);

/**
 * @brief   select high_clk as 125MHz.
 * @param   None.
 * @return  None.
 * @note
 */
void switch_to_plli(void);

/**
 * @brief   adt3102 mcu go to idle mode.
 * @param   None.
 * @return  None.
 * @note
 */
 
 /****************************************************************************************
*Function name : getSystemFreq
*Description   : get current system clock frequency
*Paramater	   : None
*        @ :  
*        @ :   

*Return        : uint8 HIGH_CLOCK_50M (1) or  HIGH_CLOCK_125M (0)
****************************************************************************************/
uint8 getSystemFreq(void);

void mcuGotoIdle(void);

/**
 * @brief   adt3102 mcu go to sleep.
 * @param   None.
 * @return  None.
 * @note
 */
void mcuGotoSleep(void);

/**
 * @brief   adt3102 setting for entering sleep mode.
 * @param   None.
 * @return  None.
 * @note
 */
void mcuSleepConfig(int32 ramOn);

/**
 * @brief   adt3102 low power mode, open or close plli or plln.
 * @param   plliOn :  open or close plli vco.
 * @param   pllnOn :  open or close plln vco.
 * @return  None.
 * @note
 */
void lowPowerSwitchPll(int32 plliOn,int32 pllnOn);

/**
 * @brief   adt3102 in the low power consumption mode, the module that can not be 
                    switched in a short time needs a long stable time.
 * @param   rx0En:  rx0 enable.
 * @param   rx1En:  rx1 enable.
 * @param   tx0En:  tx0 enable.
 * @param   tx1En:  tx1 enable.
 * @param   tiaHpf: tia hpf enable(tia0 and tia1).
 * @param   rcHpf:  rc hpf enable(rx0 and rx1).
 * @param   pgaHpf: pga hpf enable(pga0 and pga1).
 * @return  None.
 * @note
 */
void lowPowerSwitchFast(int32 rx0En, int32 rx1En, int32 tx0En, int32 tx1En, uint32 tiaHpf,uint32 rcHpf, uint32 pgaHpf);

/**
 * @brief   adt3102 in the low power consumption mode, the module that can be 
                    switched in a short time needs a short stable time.
 * @param   rx0En: rx0 enable.
 * @param   rx1En: rx1 enable.
 * @param   tx0En: tx0 enable.
 * @param   tx1En: tx1 enable.
 * @return  None.
 * @note
 */
/* If the version you are currently using is V1.5.0(the main.c header file has 
    instructions), then you need to use the second function, if you are using
    the old version, use the first. */
#ifdef COMPATIBLE
#include "common.h"
void tmp_lowPowerSwitchSlow(int32 rx0En, int32 rx1En, int32 tx0En, int32 tx1En, AnalogDataStrTypedef *pDataStr);
#else
void lowPowerSwitchSlow(int32 rx0En, int32 rx1En, int32 tx0En, int32 tx1En);
#endif 

/**
 * @brief   set adt3102 gpio is hz.
 * @param   None.
 * @return  None.
 * @note
 */
void adt3102GpioHz(void);

/**
 * @brief   rc 32KHz osc output to gpio30.
 * @param   None.
 * @return  None.
 * @note
 */
void rc32kOutputP30(void);

/**
 * @brief   setting gpio for mcu weekup.
 * @param   pinNumber: gpio number id, 0~30.
 * @param   pinPolarity: wake up edge of gpio.
 * @return  None.
 * @note
 */
void pmuGpioWakeup(uint32 pinNumber, uint32 pinPolarity);

/**
 * @brief   adjust the calibration parameters to make rc32KHz close to 32.768KHz.
 * @param   None.
 * @return  None.
 * @note
 */
void rc32kCalibration(void);

/**
 * @brief   ADC raw data output,  via P2(clk), P18~P7(bit[11:0]), P19(head).
               : 12bit format, please refer to pin mux excel document for more details. .
 * @param   enable: 1: enable.  0: disable.
 * @return  None.
 * @note
 */
void adcRawOutput(int enable);

//void pmuSleepTest(void);
#endif
